package com.apps.gomdiem.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.apps.gomdiem.R;
import com.apps.gomdiem.fragment.MenuTabFragment.OnCheckBoxClickedListener;
import com.apps.gomdiem.model.ListTempMenu;
import com.apps.gomdiem.model.MainModel;
import com.apps.gomdiem.model.MenuList;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;

public class CatalogChoiceMenuAdapter extends BaseAdapter {
	ArrayList<ListTempMenu> arrayMenu;
	Context context;

	public CatalogChoiceMenuAdapter(ArrayList<ListTempMenu> arrayList, Context contxt) {
		arrayMenu = arrayList;
		context = contxt;
	}

	public void update(ArrayList<ListTempMenu> listMenu) {
		this.arrayMenu = listMenu;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return arrayMenu.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return arrayMenu.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		ViewHolder viewHolder;
		if (convertView == null) {
			LayoutInflater ltInflate = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			viewHolder = new ViewHolder();
			convertView = ltInflate.inflate(R.layout.catalog_choices_menu, null);
			viewHolder.nameOfMenu = (TextView) convertView.findViewById(R.id.txtNameOfMenu);
			viewHolder.quantity = (TextView) convertView.findViewById(R.id.txtQuantity);
			viewHolder.price=(TextView) convertView.findViewById(R.id.txtPrice);
			
			convertView.setTag(viewHolder);
			
		

		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		
		viewHolder.nameOfMenu.setText(arrayMenu.get(position).nameMenu);
		viewHolder.quantity.setText(Integer.toString(arrayMenu.get(position).quantity));
		viewHolder.price.setText(Integer.toString(arrayMenu.get(position).price));
		return convertView;
	}

	private class ViewHolder {
		TextView nameOfMenu,quantity,price;
	}
	
}
